<template>
    <div id="app">
        <router-view></router-view>
    </div>
</template>

<script>

export default {
    name: 'App',
    mounted() {
        var logined = sessionStorage.logined;
        // console.log(logined)
        if (logined === 'true') {   //大坑：sessionStorage取出来的值都是string型
            // console.log('我是logined')
            this.$router.push('/')
        } else {
            // console.log('我是unlogined')
            this.$router.push('/login')
        }

        console.log(`北京邮电大学2020级本科学生：\n邹伟峰 李馨琪 郭俊杰, \n问好!!! \n              ——于2023年夏`)

        //本地持久化state
        window.addEventListener('unload', this.saveState);
    },

    methods: {
        saveState(){
            sessionStorage.state = JSON.stringify(this.$store.state);  //对象存储在本地时需要JSON转换
        }
    }
}
</script>

<style>
#app {
    font-family: Avenir, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: #2c3e50;
    margin-top: 0px;
}
</style>
